package reflectPracticeDemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

//通过注解来实现Student类的方法
@AnnotationPractice(file = "reflectPracticeDemo.Student", methed = "methed1")
public class AnnotationPracticeDemo {

	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
		Class<AnnotationPracticeDemo> a = AnnotationPracticeDemo.class;
		
		AnnotationPractice ap = a.getAnnotation(AnnotationPractice.class);
		
		String file = ap.file();
		String methed = ap.methed();
		
		Class<?> name = Class.forName(file);
		Constructor<?> constructor = name.getConstructor(null);
		Object newInstance = constructor.newInstance();
		
		Method method = name.getMethod(methed, null);
		method.invoke(newInstance, null);
		
		
		

	}

}
